import React from 'react';
import { observer, inject } from 'mobx-react';
import { withRouter, Route } from 'react-router-dom';
import { List, InputItem, Icon, Tools } from 'weaver-mobile';
import { RouteLayout } from 'weaver-mobile-page';

const Item = List.FormItem;
const ButtonGroup = RouteLayout.ButtonGroup;

@inject('homePageTestStore')
@withRouter
@observer
export default class SingleSign extends React.Component {
  componentDidMount() {
    if (window.em && window.em.checkJsApi("configNavigation")) {
      window.em.ready(function () {
        window.em.configNavigation({
          'success': function (argument) { },
          'fail': function (argument) { },
          'cancel': function (argument) { },
          'complete': function (argument) { },
          'title': Tools.getLabel(126789, '单点登录'),
        })
      });
    }
  }
  render() {
    const { homePageTestStore: { username, password, insertAccount, setState } } = this.props;
    return (
      <div>
        <List>
          <Item
            line
            content={(<InputItem
              value={username}
              placeholder="请输入"
              onChange={(v) => { setState({ username: v }) }}
            />)}
            label="账号"
            extra={[<Icon key="right" type="right" />]}
            requried></Item>
          <Item
            line
            content={(<InputItem
              type='password'
              value={password}
              placeholder="请输入"
              onChange={(v) => { setState({ password: v }) }}
            />)}
            label="密码"
            extra={[<Icon key="right" type="right" />]}
            requried></Item>
        </List>
        <ButtonGroup data={[
          {
            key: 'save',
            text: '登录',
            onClick: () => {
              insertAccount(this.props.history);
            },
            type: 'primary',
          },
        ]} />
      </div>
    )
  }

}
